# 朴素贝叶斯

from sklearn.preprocessing import StandardScaler
from sklearn.naive_bayes import MultinomialNB
from sklearn.metrics import classification_report
import load_data

x_train, y_train, x_test, y_test = load_data.load()

ss = StandardScaler(with_mean=False)
x_train = ss.fit_transform(x_train)
x_test = ss.transform(x_test)

mnb = MultinomialNB()
mnb.fit(x_train, y_train)

y_test_predict = mnb.predict(x_test)
y_train_predict = mnb.predict(x_train)

print('Test Dataset Accruacy of Naive-Bayes Classifier:', mnb.score(x_test, y_test))
print(classification_report(y_test, y_test_predict, target_names=['group1', 'group2', 'group3']))

print('Train Dataset Accruacy of Naive-Bayes Classifier:', mnb.score(x_train, y_train))
print(classification_report(y_train, y_train_predict, target_names=['group1', 'group2', 'group3']))
